'''
Created on Apr 6, 2011

@author: oabalbin
This script takes a vcf file such as dbSNP or HapMap or a 
file with validated SNPs and build and dump the files
for later use as annotation source 
'''
from optparse import OptionParser
from exome.vcftools.vcf import *

def read_file(ivcf,pfname):
    
    thisvcf=VCF()
    thisvcf.readFromFile(ivcf)
    snvs = thisvcf.keys()
    thisvcf.pickle(pfname)
    
    print snvs

    return snvs


if __name__ == '__main__':
    optionparser = OptionParser("usage: %prog [options] ")
    
    # Specific options
    optionparser.add_option("-f", "--vcf_files", action="append", type="str",
                            dest="vcf_files",
                            help="others_vcf_files. Pass vcf files without .gz extention even if the file .gz is there")

    (options, args) = optionparser.parse_args()
        
    for tf in options.vcf_files:
        pfname = tf.replace('.vcf','.dump')
        read_file(tf,pfname)
        